from django.shortcuts import render
from django.http import HttpResponse,JsonResponse
import os,json
import uuid

def push_image(request):
    if request.method == "POST":
        image = request.FILES['file']
        uuid1 = uuid.uuid4()
        BASE_STATIC = '/home/seal/st/backend/static/'
        path = BASE_STATIC +'images/'
        if not os.path.exists(path + "%s" % uuid1 +'.jpg'):
            with open(path+ "%s" % uuid1 +'.jpg','wb') as f:
                f.write(image.read())
                f.close()
            # def url = '121.41.107.81:28001/static/images/' + uuid +'.jpg'
            # return url
            return HttpResponse("上传成功")
        return HttpResponse("重复")
    if request.method != "POST": 
        return HttpResponse("NOT POST")

